import React, { useState } from 'react';
import { Table, } from 'antd';
import store from './../../../redux/store';
import {createCheckedAction} from './../../../redux/action/customerAction/tableCheck';
import './style.css'



export default function MyTable(props) {
  const { columns, data } = props
  // const [checkedInfo, setcheckedInfo] = useState([]);
  //勾选后，将选中的客户信息存入redux。
  const handleCheck = (selectedRowKeys, selectedRows) => {
    // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
    // console.log('selectedRows: ', selectedRows);
    // setcheckedInfo(selectedRows)
    store.dispatch(createCheckedAction(selectedRows))
  }

  return (
    <div>
      <Table className='mytable' style={{ height: '410px', overflowY: 'scroll' }} pagination={false} dataSource={data} columns={columns} rowSelection={{
        type: 'checkbox',
        onChange: handleCheck,
      }}>
      </Table>
    </div>
  )
}
